package com.atguigu.oss.utill;

import javafx.fxml.Initializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.naming.spi.InitialContextFactory;

/**
 * @author: He Wentao
 * @date: 2022/8/19 22:16
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@ConfigurationProperties("qiniu")
public class ConstantPropertiesUtils implements InitializingBean {
    private String access_key;
    private String secret_key;
    private String bucket_name;
    private String domain;

    // 为了方便使用，可以直接 类名.ACCESS_KEY
    // 为什么这样写？ 经过测试，静态遍历无法注入。。。。
    public static String ACCESS_KEY;
    public static String SECRET_KEY;
    public static String BUCKET_NAME;
    public static String DOMAIN;

    @Override
    public void afterPropertiesSet() throws Exception {

       ACCESS_KEY = this.access_key;
       SECRET_KEY = this.secret_key;
       BUCKET_NAME = this.bucket_name;
       DOMAIN = this.domain;
    }
}


